package api

import (
	"net/http"
	"study/go-blog/common"
	"study/go-blog/service"
)

func (*Api) Login(response http.ResponseWriter, request *http.Request) {
	//接收用户名密码，返回json数据
	params := common.GetRequestJsonParams(request)
	username := params["username"].(string)
	password := params["passwd"].(string)
	loginRes, err := service.Login(username, password)
	if err != nil {
		common.Error(response, err)
		return
	}
	common.Success(response, loginRes)
}
